<?php

namespace app\index\model;

use think\Model;

class Messages extends Model
{
    public function user_messages(){
        return $this->hasMany('article','id', 'article_id');
    }

    public function get_user_messages($user_id){

    }

        public function get_messages($id){
            $res = db('messages')->where('a.article_id', $id)->order('create_time desc')->field('a.*,b.name')->alias('a')->join('lan_users b','a.user_id=b.id')->select();
            // $res = Messages::all($id);
            return $res;
        }

        public function get_mess_user(){
            $res = db('messages')->where('a.article_id', 0)->order('create_time desc')->field('a.*,b.name')->alias('a')->join('lan_users b','a.user_id=b.id')->select();
            return $res;
        }
}
